home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / drdobbs / ddjcompr / hstest / src / memid.asm < prev    next >
Assembly Source File  |  1991-02-05  |  1KB  |  70 lines

  1.     NAME    memid
  2.  
  3. include tomlib.equ
  4.  
  5. ;-----------------------------------------------------
  6. ;   memid(near *dest,near *src)
  7. ;                               return number of equal bytes
  8. ;    {
  9. ;         register int loop;
  10. ;         for (loop = 0; *dest++ == *src++; loop++)
  11. ;             ;
  12. ;         return loop;
  13. ;     }
  14. ;------------------------------------------------------
  15.   
  16. TEXTSEGMENT
  17.  
  18.     PUBPROC  _memid
  19. ;------------------------------------------------------------------------------
  20.  
  21.     mov        dx,di                ; protect DI && SI
  22.     mov        bx,si
  23.     mov        si,sp
  24.  
  25.     mov        ax,ds
  26.     mov        es,ax
  27.  
  28.     mov     di,(2+SPOFF)[si]
  29.     mov     si,(4+SPOFF)[si]
  30.     mov        cx,0ffffh
  31.     cld
  32.     repe cmpsb
  33.     mov        ax,-2
  34.     sub        ax,cx
  35.  
  36.     mov        di,dx
  37.     mov        si,bx
  38.     ret
  39. ;------------------------------------------------------------------------------
  40. _memid endp
  41.  
  42.     PUBPROC  @memid                ; registers in AX,BX
  43. ;------------------------------------------------------------------------------
  44.  
  45.     xchg    ax,si
  46.     xchg    bx,di                ; protect DI && SI
  47.  
  48.     mov        cx,ds
  49.     mov        es,cx
  50.  
  51.     mov        cx,0ffffh
  52.     cld
  53.     repe cmpsb
  54.  
  55.     xchg    ax,si
  56.     xchg    bx,di                ; unprotect DI && SI
  57.  
  58.     mov        ax,-2
  59.     sub        ax,cx
  60.  
  61.     ret
  62. ;------------------------------------------------------------------------------
  63. @memid endp
  64.  
  65. TEXTEND
  66.     end
  67.